<template>
    <div id="inspection-task" class="w-h-100 pos-r flex-1 apply-container page-public-s" style="box-sizing: border-box;overflow:hidden;">
        <div class="w-h-100 ver-flex pos-a" style="box-sizing: border-box; padding: 6px;">
            <div v-if="$hasPer('TaskLedger:add') || $hasPer('TaskLedger:excel')" style="box-sizing: border-box;">
                <el-card shadow="never" :body-style="{ paddingBottom: '0' }">
                    <el-form class="box-f" ref="queryForm" :inline="true">
                        <el-form-item>
                            <el-button style="margin: 0 10px 5px 0;" v-if="$hasPer('TaskLedger:add')" @click="nodeClick('')" icon="ele-Plus" type="primary"> 新增 </el-button>
                            <el-button style="margin: 0 10px 5px 0;" @click="syncHandle(getData)" icon="ele-Refresh"> 批量同步 </el-button>
                            <el-button style="margin: 0 10px 5px 0;" v-if="$hasPer('TaskLedger:excel')" @click="handleExport" icon="ele-Download"> 导出数据 </el-button>
                            <el-button style="margin: 0 10px 5px 0;" :class="{'itemClass' : setItemClass === 6}"  @click="stateClick(6)" class="icon-e set-border" text>巡检任务总数量<span style="color: #409EFF;margin-left: 5px;">{{ state.n_AllRecordCount }}</span></el-button>
                            <el-button style="margin: 0 10px 5px 0;" :class="{'itemClass' : setItemClass === 0}"  @click="stateClick(0)" class="icon-e set-border" text>待提交记录数量<span style="color: #67C23A;margin-left: 5px;">{{ state.n_DraftRecordCount }}</span></el-button>
                            <el-button style="margin: 0 10px 5px 0;" :class="{'itemClass' : setItemClass === 1}"  @click="stateClick(1)" class="icon-e set-border" text>未开始记录数量<span style="color: #865205;margin-left: 5px;">{{ state.n_TodoRecordCount }}</span></el-button>
                            <el-button style="margin: 0 10px 5px 0;" :class="{'itemClass' : setItemClass === 2}"  @click="stateClick(2)" class="icon-e set-border" text>执行中记录数量<span style="color: #E6A23C;margin-left: 5px;">{{ state.n_DoingRecordCount }}</span></el-button>
                            <el-button style="margin: 0 10px 5px 0;" :class="{'itemClass' : setItemClass === 3}"  @click="stateClick(3)" class="icon-e set-border" text>已完成记录数量<span style="color: #F56C6C;margin-left: 5px;">{{ state.n_CompletedRecordCount }}</span></el-button>
                            <el-button style="margin: 0 10px 5px 0;" :class="{'itemClass' : setItemClass === 4}"  @click="stateClick(4)" class="icon-e set-border" text>漏检记录数量<span style="color: #c6ff40;margin-left: 5px;">{{ state.n_MissRecordCount }}</span></el-button>
                            <el-button style="margin: 0 10px 5px 0;" :class="{'itemClass' : setItemClass === 5}"  @click="stateClick(5)" class="icon-e set-border" text>取消记录数量<span style="color: #9e1fd9;margin-left: 5px;">{{ state.n_CancelRecordCount }}</span></el-button>
                        </el-form-item>
                    </el-form>
                </el-card>
            </div>

            <div style="box-sizing: border-box;" class="flex-1 pos-r">
                <div class="pos-a w-h-100" style="box-sizing: border-box;">
                    <el-card class="box-card w-h-100" shadow="never" style="margin-top: 16px;">
                        <div style="" class="w-h-100 ver-flex">
                            <div class="flex-1 pos-r">
                                <div class="pos-a w-h-100">
                                    <el-table 
                                        ref="excelRef"
                                        :data="list" 
                                        class="w-h-100" 
                                        style="width: 100%" 
                                        border 
                                        v-loading="loading" 
                                        element-loading-background="rgba(0, 0, 0, 0.5)"
                                        @selection-change="handleSelectionChange"
                                    >
                                    <el-table-column 
                                        type="selection" 
                                        width="55" 
                                        fixed="left"
                                    />  
                                    
                                        <el-table-column width="80" :show-overflow-tooltip="true" label="待同步"  align="center">
                                            <template #default="scope">
                                                <span style="color: #67C23A;" v-if="scope.row.isTobeDS">是</span>
                                                <span v-else> - </span>
                                            </template>
                                        </el-table-column>

                                        <el-table-column min-width="200" :show-overflow-tooltip="true" label="任务名称"  align="center">
                                            <el-table-column :show-overflow-tooltip="true" min-width="200" align="center">
                                                <template #header>
                                                    <SearchModel typeId="i_Name" typeVal="input" @searchHandel="searchHandel" :basicsInfo="basicsInfo" />
                                                </template>
                                                <template #default="scope">
                                                    <span v-if="scope.row.v_Name">{{ scope.row.v_Name }}</span>
                                                    <span v-else> - </span>
                                                </template>
                                            </el-table-column>
                                        </el-table-column>

                                        <el-table-column min-width="200" :show-overflow-tooltip="true" label="巡检计划名称"  align="center">
                                            <el-table-column :show-overflow-tooltip="true" min-width="200" align="center">
                                                <template #header>
                                                    <SearchModel typeId="s_Plan" typeVal="select" @searchHandel="searchHandel" :basicsInfo="basicsInfo" />
                                                </template>
                                                <template #default="scope">
                                                    <span v-if="scope.row.v_IPPlanName">{{ scope.row.v_IPPlanName }}</span>
                                                    <span v-else> - </span>
                                                </template>
                                            </el-table-column>
                                        </el-table-column>

                                        <el-table-column min-width="200" :show-overflow-tooltip="true" label="风险分区"  align="center">
                                            <el-table-column :show-overflow-tooltip="true" min-width="200" align="center">
                                                <template #header>
                                                    <SearchModel typeId="s_Risk" typeVal="select" @searchHandel="searchHandel" :basicsInfo="basicsInfo" />
                                                </template>
                                                <template #default="scope">
                                                    <span v-if="scope.row.v_RiskPartitionName">{{ scope.row.v_RiskPartitionName }}</span>
                                                    <span v-else> - </span>
                                                </template>
                                            </el-table-column>
                                        </el-table-column>

                                        <el-table-column min-width="200" :show-overflow-tooltip="true" label="巡检分类"  align="center">
                                            <template #default="scope">
                                                <span v-if="scope.row.v_IPClassName">{{ scope.row.v_IPClassName }}</span>
                                                <span v-else> - </span>
                                            </template>
                                        </el-table-column>

                                        <el-table-column min-width="200" :show-overflow-tooltip="true" label="任务状态"  align="center" fixed="right">
                                            <el-table-column :show-overflow-tooltip="true" min-width="200" align="center">
                                                <template #header>
                                                    <SearchModel typeId="s_State" typeVal="select" @searchHandel="searchHandel" :basicsInfo="basicsInfo" />
                                                </template>
                                                <template #default="scope">
                                                    <span v-if="scope.row.n_State === 0" style="color: #909399;">{{ scope.row.v_StateName }}</span>
                                                    <span v-if="scope.row.n_State === 1" style="color: #E6A23C;">{{ scope.row.v_StateName }}</span>
                                                    <span v-if="scope.row.n_State === 2" style="color: #67C23A;">{{ scope.row.v_StateName }}</span>
                                                    <span v-if="scope.row.n_State === 3" style="color: #409EFF;">{{ scope.row.v_StateName }}</span>
                                                    <span v-if="scope.row.n_State === 4" style="color: #F56C6C;">{{ scope.row.v_StateName }}</span>
                                                    <span v-if="scope.row.n_State === 5" style="color: #865205;">{{ scope.row.v_StateName }}</span>
                                                </template>
                                            </el-table-column>
                                        </el-table-column>

                                        <el-table-column min-width="200" :show-overflow-tooltip="true" label="巡检路线"  align="center">
                                            <el-table-column :show-overflow-tooltip="true" min-width="200" align="center">
                                                <template #header>
                                                    <SearchModel typeId="s_Path" typeVal="select" @searchHandel="searchHandel" :basicsInfo="basicsInfo" />
                                                </template>
                                                <template #default="scope">
                                                    <span v-if="scope.row.v_IPPathName">{{ scope.row.v_IPPathName }}</span>
                                                    <span v-else> - </span>
                                                </template>
                                            </el-table-column>
                                        </el-table-column>

                                        <el-table-column min-width="200" :show-overflow-tooltip="true" label="巡检类型"  align="center">
                                            <el-table-column :show-overflow-tooltip="true" min-width="200" align="center">
                                                <template #header>
                                                    <SearchModel typeId="s_Type" typeVal="select" @searchHandel="searchHandel" :basicsInfo="basicsInfo" />
                                                </template>
                                                <template #default="scope">
                                                    <span v-if="scope.row.v_IPType">{{ scope.row.v_IPType }}</span>
                                                    <span v-else> - </span>
                                                </template>
                                            </el-table-column>
                                        </el-table-column>

                                        <el-table-column width="230" :show-overflow-tooltip="true" label="任务计划开始时间"  align="center" prop="d_PlanStartTime" sortable>
                                            <el-table-column :show-overflow-tooltip="true" width="230" align="center">
                                                <template #header>
                                                    <SearchModel typeId="d_Start" typeVal="datetime" @searchHandel="searchHandel" :basicsInfo="basicsInfo" />
                                                </template>
                                                <template #default="scope">
                                                    <span v-if="scope.row.d_PlanStartTime">{{ scope.row.d_PlanStartTime }}</span>
                                                    <span v-else> - </span>
                                                </template>
                                            </el-table-column>
                                        </el-table-column>

                                        <el-table-column width="230" :show-overflow-tooltip="true" label="任务计划结束时间"  align="center" prop="d_PlanEndTime" sortable>
                                            <el-table-column :show-overflow-tooltip="true" width="230" align="center">
                                                <template #header>
                                                    <SearchModel typeId="d_End" typeVal="datetime" @searchHandel="searchHandel" :basicsInfo="basicsInfo" />
                                                </template>
                                                <template #default="scope">
                                                    <span v-if="scope.row.d_PlanEndTime">{{ scope.row.d_PlanEndTime }}</span>
                                                    <span v-else> - </span>
                                                </template>
                                            </el-table-column>
                                        </el-table-column>

                                        <el-table-column width="230" :show-overflow-tooltip="true" label="任务实际开始时间"  align="center" prop="d_StartTime" sortable>
                                            <el-table-column :show-overflow-tooltip="true" width="230" align="center">
                                                <template #header>
                                                    <SearchModel typeId="d_StartTime" typeVal="datetime" @searchHandel="searchHandel" :basicsInfo="basicsInfo" />
                                                </template>
                                                <template #default="scope">
                                                    <span v-if="scope.row.d_StartTime">{{ scope.row.d_StartTime }}</span>
                                                    <span v-else> - </span>
                                                </template>
                                            </el-table-column>
                                        </el-table-column>

                                        <el-table-column width="230" :show-overflow-tooltip="true" label="任务实际结束时间"  align="center" prop="d_EndTime" sortable>
                                            <el-table-column :show-overflow-tooltip="true" width="230" align="center">
                                                <template #header>
                                                    <SearchModel typeId="d_EndTime" typeVal="datetime" @searchHandel="searchHandel" :basicsInfo="basicsInfo" />
                                                </template>
                                                <template #default="scope">
                                                    <span v-if="scope.row.d_EndTime">{{ scope.row.d_EndTime }}</span>
                                                    <span v-else> - </span>
                                                </template>
                                            </el-table-column>
                                        </el-table-column>

                                        <el-table-column min-width="200" :show-overflow-tooltip="true" label="实际执行人名称"  align="center">
                                            <el-table-column :show-overflow-tooltip="true" min-width="200" align="center">
                                                <template #header>
                                                    <SearchModel typeId="s_Executor" typeVal="select" @searchHandel="searchHandel" :basicsInfo="basicsInfo" />
                                                </template>
                                                <template #default="scope">
                                                    <span v-if="scope.row.v_ExecutorName">{{ scope.row.v_ExecutorName }}</span>
                                                    <span v-else> - </span>
                                                </template>
                                            </el-table-column>
                                        </el-table-column>

                                        <el-table-column min-width="120" :show-overflow-tooltip="true" label="处理过程"  align="center" fixed="right">
                                            <template #default="scope">
                                                <el-button @click="resultHandle(2,scope.row)" class="icon-e" icon="ele-View" size="small" text type="primary">查看</el-button>
                                            </template>
                                        </el-table-column>

                                        <el-table-column min-width="120" :show-overflow-tooltip="true" label="巡检结果"  align="center" fixed="right">
                                            <template #default="scope">
                                                <el-button @click="resultHandle(0,scope.row)" class="icon-e" icon="ele-View" size="small" text type="success">查看</el-button>
                                            </template>
                                        </el-table-column>

                                        <el-table-column min-width="120" :show-overflow-tooltip="true" label="其它隐患"  align="center" fixed="right">
                                            <template #default="scope">
                                                <el-button @click="resultHandle(1,scope.row)" class="icon-e" icon="ele-View" size="small" text type="warning">查看</el-button>
                                            </template>
                                        </el-table-column>

                                        <el-table-column min-width="200" :show-overflow-tooltip="true" label="实际执行人部门名称"  align="center">
                                            <el-table-column :show-overflow-tooltip="true" min-width="200" align="center">
                                                <template #header>
                                                    <SearchModel typeId="s_Dept" typeVal="cascader" @searchHandel="searchHandel" :basicsInfo="basicsInfo" />
                                                </template>
                                                <template #default="scope">
                                                    <span v-if="scope.row.v_ExecutorDeptName">{{ scope.row.v_ExecutorDeptName }}</span>
                                                    <span v-else> - </span>
                                                </template>
                                            </el-table-column>
                                        </el-table-column>

                                        <el-table-column min-width="180" :show-overflow-tooltip="true" prop="createdTime" label="创建时间"  align="center" sortable>
                                            <template #default="scope">
                                                <span v-if="scope.row.createdTime">{{ scope.row.createdTime }}</span>
                                                <span v-else>-</span>
                                            </template>
                                        </el-table-column>

                                        <el-table-column min-width="180" :show-overflow-tooltip="true" prop="updatedTime" label="更新时间"  align="center" sortable>
                                            <template #default="scope">
                                                <span v-if="scope.row.updatedTime">{{ scope.row.updatedTime }}</span>
                                                <span v-else>-</span>
                                            </template>
                                        </el-table-column>
                                        
                                        <el-table-column min-width="180" :show-overflow-tooltip="true" label="最后一次同步时间"  align="center">
                                            <template #default="scope">
                                                <span v-if="scope.row.d_InitiateDSTime">{{ scope.row.d_InitiateDSTime }}</span>
                                                <span v-else> - </span>
                                            </template>
                                        </el-table-column>
                                        
                                        <el-table-column width="180" :show-overflow-tooltip="true" label="发起同步时间"  align="center">
                                            <template #default="scope">
                                                <span v-if="scope.row.d_InitiateDSTime">{{ scope.row.d_InitiateDSTime }}</span>
                                                <span v-else> - </span>
                                            </template>
                                        </el-table-column>

                                        <el-table-column width="300" label="操作" align="center" fixed="right">
                                            <el-table-column :show-overflow-tooltip="true" min-width="300" align="center">
                                                <template #header>
                                                    <el-button class="icon-e" @click='searchClick' icon="ele-Search" size="small" type="primary" text> 查询 </el-button>
                                                    <el-button class="icon-e clear-bg" style="background-color: transparent !important;" size="small" @click="resetClick" icon="ele-Refresh" text> 重置 </el-button>
                                                </template>
                                                <template #default="scope">
                                                    <el-button @click="detailHandle(scope.row.id)" class="icon-e" icon="ele-View" size="small" text type="success">详情</el-button>
                                                    <template v-if="scope.row.n_State === 0">
                                                        <el-button v-if="$hasPer('TaskLedger:edit')" @click="nodeClick(scope.row)" class="icon-e" icon="ele-Edit" size="small" text type="primary">编辑</el-button>
                                                        <el-button v-if="$hasPer('TaskLedger:del')" @click="deleteHandle(scope.row.id, getData)" class="icon-e" icon="ele-Delete" size="small" text type="danger">删除</el-button>
                                                        <el-button v-if="$hasPer('TaskLedger:submit')" @click="funClick(scope.row,0,getData)" class="icon-e" icon="ele-Finished" size="small" text type="warning">任务提交</el-button>
                                                    </template>
                                                    <template v-else-if="scope.row.n_State === 5">
                                                        <el-button v-if="$hasPer('TaskLedger:edit')" @click="nodeClick(scope.row)" class="icon-e" icon="ele-Edit" size="small" text type="primary">编辑</el-button>
                                                        <el-button v-if="$hasPer('TaskLedger:del')" @click="deleteHandle(scope.row.id, getData)" class="icon-e" icon="ele-Delete" size="small" text type="danger">删除</el-button>
                                                        <el-button v-if="$hasPer('TaskLedger:anewStart')" @click="funClick(scope.row,2,getData)" class="icon-e" icon="ele-Finished" size="small" text type="warning">任务重新启动</el-button>
                                                    </template>
                                                    <template v-else-if="scope.row.n_State === 3">
                                                        <el-button v-if="$hasPer('TaskLedger:finish')" class="icon-e" icon="ele-Finished" size="small" text type="success">巡检任务完成</el-button>
                                                    </template>
                                                    <template v-else-if="scope.row.n_State === 2">
                                                        <el-button v-if="$hasPer('TaskLedger:turn')" class="icon-e" icon="ele-Finished" @click="funClick(scope.row,4,getData)" size="small" text type="primary">任务转办</el-button>
                                                    </template>
                                                    <template v-else>
                                                        <el-dropdown v-if="$hasPer('TaskLedger:cancel') || $hasPer('TaskLedger:execute')" trigger="click">
                                                            <el-button style="margin:0 10px;" class="el-dropdown-link" size="small" text type="warning">功能菜单<el-icon class="el-icon--right"><arrow-down /></el-icon></el-button>
                                                            <template #dropdown>
                                                                <el-dropdown-menu>
                                                                    <el-dropdown-item v-if="scope.row.n_State === 1 && $hasPer('TaskLedger:cancel')" @click="funClick(scope.row,1,getData)" icon="CollectionTag">任务取消</el-dropdown-item>
                                                                    <el-dropdown-item v-if="scope.row.n_State === 1 && $hasPer('TaskLedger:execute')" @click="funClick(scope.row,3,getData)" icon="Edit">任务开始执行</el-dropdown-item>
                                                                    <!-- <el-dropdown-item v-if="scope.row.n_State === 1" @click="funClick(scope.row,4,getData)" icon="List">任务转办</el-dropdown-item> -->
                                                                    <!-- <el-dropdown-item v-if="scope.row.n_State === 2 && $hasPer('InspectionTask:phone')" @click="funClick(scope.row,5,getData)" icon="List">问题随手拍</el-dropdown-item> -->
                                                                    <!-- <el-dropdown-item v-if="scope.row.n_State === 2" @click="funClick(scope.row,6,getData)" icon="List">登记巡检结果</el-dropdown-item> -->
                                                                </el-dropdown-menu>
                                                            </template>
                                                        </el-dropdown>
                                                    </template>
                                                </template>
                                            </el-table-column>
                                        </el-table-column>
                                    </el-table>
                                </div>
                            </div>
                            <div style="height: 30px;margin-top: 20px;" class="hr-flex-start">
								<el-pagination
									v-model:currentPage="pageNo"
									v-model:page-size="pageSize"
									:total="totalRows"
									:page-sizes="[10, 20, 50, 100]"
									small
									background
									@size-change="handleSizeChange"
									@current-change="handleCurrentChange"
									layout="total, sizes, prev, pager, next, jumper"
									class="w-h-100"
								/>
							</div>
                        </div>
                    </el-card>
                </div>
            </div>
        </div>
        <AddEditInspectionTask
            preType="equ"
            :repairInfo="repairInfo"
            :isUseDialog="isUseDialog"
            @updateData="getData"
            @cancelUseClick="cancelUseClick"
            @controlUseClick="controlUseClick"
        />
        <!-- 表单模型 -->
        <ModelDialog 
            :isDialog="isDialog"
            :modelInfo="modelInfo"
            @cancelModelClick="cancelModelClick"
            @controlModelClick="controlModelClick"
        />
        <!-- 问题随手拍 -->
        <IssuePhoto
            :isPhoto="isPhoto"
            :photoInfo="photoInfo"
            @cancelPhotoClick="cancelPhotoClick"
        ></IssuePhoto>
        <!-- 登记巡检结果 -->
        <RegisterResult
            :resultDialog="resultDialog"
            :resultInfo="resultInfo"
            @cancelResultClick="cancelResultClick"
            @controlResultClick="controlResultClick"
            @updateData="getData"
        ></RegisterResult>
        <!-- 详情 -->
        <DetailModel
            :detailInfo="detailInfo"
            :MdetailDialog="MdetailDialog"
            labelWidth="170px"
            @cancelDetailClick="cancelDetailClick"
        />
        <!-- 巡检结果/其它隐患 -->
        <ResultView
            :effectInfo="effectInfo"
            :effectDialog="effectDialog"
            @effectClick="effectClick"
        />
        <!-- 处理过程 -->
        <DisposeCourse
            statusVal="dispose"
            :dispInfo="dispInfo"
            :dispDialog="dispDialog"
            @dispClick="dispClick"
        />
    </div>
</template>
<script lang="ts">
import { defineComponent, ref, Ref, onMounted , reactive , toRaw , toRefs } from 'vue';
import getTableData from '/@/utils/getTableData';
import { 
    SMSIPTaskPage,
    SMSIPTaskDelete, 
    SMSIPTaskSubmit, 
    SMSIPTaskCancel,
    SMSIPTaskReStart,
    SMSIPTaskStart,
    SMSIPTaskTransfer,
    SMSIPTaskTaskStatisticsRecordCount,
    SMSIPPlanList,
    SMSDCRiskPartitionList,
    SMSIPPathList,
    sysDictDataList,
    SMSIPTaskDetail,
    SMSDCSysDSTaskMaBathAddTasks,
} from '/@/api/centerControl/sms';
import { sysOrgTree , sysUserselectorV2 } from '/@/api/centerControl/pubilc';
import AddEditInspectionTask from '../component/sms/add-edit-InspectionTask.vue';
import ModelDialog from '../component/model-dialog.vue';
import { messageFun , confirmFun } from '../component/messageTs';
import { ElMessageBox , ElMessage } from 'element-plus';
import { sysUserPage } from '/@/api/centerControl/pubilc';
import uploadFile from '../component/uploadFile.vue';
import IssuePhoto from '../component/sms/issue-photo.vue';
import RegisterResult from '../component/sms/register-result.vue';
import SearchModel from '../component/search-model.vue';
import DetailModel from '../component/detail-model.vue';
import ResultView from '../component/sms/result-view.vue';
import DisposeCourse from '../component/sms/dispose-course.vue';
import { exportToExcel } from '/@/utils/exportToExcel';

export default defineComponent( {
    name: 'inspection-task',
    components: {
        AddEditInspectionTask,
        ModelDialog,
        uploadFile,
        IssuePhoto,
        RegisterResult,
        SearchModel,
        DetailModel,
        ResultView,
        DisposeCourse,
    },
    setup(props){
        const isUseDialog = ref() // 新增/编辑弹出框隐藏/显示
        const repairInfo = ref() // 传递子组件数据
        const modelInfo = ref('');
        let funFun: Function;
        let needId: Number;
        const fileInfo = ref();
        const fileDialog = ref(false);
        const isPhoto = ref(false);
        const photoInfo = ref('');
        const resultDialog = ref(false);
        const resultInfo = ref('');
        const setItemClass = ref(6);

        const effectInfo = ref();
        const effectDialog  = ref(false);
        const dispInfo = ref();
        const dispDialog = ref(false);
        let multipleSelection: any = [];

        const state: any = reactive({
            n_AllRecordCount: 0,
            n_CancelRecordCount: 0,
            n_CompletedRecordCount: 0,
            n_DoingRecordCount: 0,
            n_DraftRecordCount: 0,
            n_MissRecordCount: 0,
            n_TodoRecordCount: 0,
        });

        /*** 批量同步数据按钮 */
        const syncHandle = (uploadFun: Function) => {
            let setArr: any = [];
            if(multipleSelection.length === 0){
                ElMessage({
                    type: 'warning',
                    message: '请选择需同步的数据',
                });
                return;
            }else{
                confirmFun('是否批量同步已选数据，注意：该操作仅同步已完成或取消的数据。','提示','warning','取消').then(async(isConfirmed: any) => {
                    if(isConfirmed){
                        multipleSelection.map((item: any) => {
                            if(item.n_State === 3 || item.d_LastDSTime !== null){
                                setArr.push(item.id);
                            }
                        });
                        let res: any = await SMSDCSysDSTaskMaBathAddTasks({ n_DCSysDSTaskType: 4, l_AppInstanceIds: setArr });
                        if(res.success) uploadFun();
                    }
                });
            }
        }
        const handleSelectionChange = (val: any) => {
            multipleSelection = val;
        }

        /*** 功能菜单点击事件 */
        const funClick = async(val: object | any , num: number , uploadFun: Function) => {
            let confirmVal: any;
            switch(num){
                case 0:
                    confirmVal = confirmFun('是否发布任务？','提示','warning','取消发布');
                    confirmVal.then((isConfirmed: any) => {
                        if(isConfirmed) funBtn(SMSIPTaskSubmit,num,val,uploadFun);
                    });
                    break;
                case 1:
                    let getVal = messageFun('任务取消原因');
                    getVal.then((res: any) => {
                        val.message = res;
                        funBtn(SMSIPTaskCancel,num,val,uploadFun);
                    })
                    break;
                case 2:
                    confirmVal = confirmFun('是否重新启动任务？','提示','warning','取消重新启动');
                    confirmVal.then((isConfirmed: any) => {
                        if(isConfirmed) funBtn(SMSIPTaskReStart,num,val,uploadFun);
                    });
                    break;
                case 3:
                    confirmVal = confirmFun('是否开始执行任务？','提示','warning','取消执行');
                    confirmVal.then((isConfirmed: any) => {
                        if(isConfirmed) funBtn(SMSIPTaskStart,num,val,uploadFun);
                    });
                    break;
                case 4:
                    // 基础验证
                    let basicForms = {
                        l_ExecutorId: '',
                    };
                    // 表单基础设置
                    let modelBscs: any = {
                        modeWidth: '60%',
                        labelWidth: '100px',
                        rules: {l_ExecutorId:[{required: true, message: '请选择转办角色', trigger: 'change'}],},
                        cancelInfo: '取消',
                        controlInfo: '确定',
                        titleCon: '任务转办',
                    };
                    // 表单核心内容设置
                    let modelForms: any = [
                        {
                            type: 'select', 
                            label: '转办人', 
                            prop: 'l_ExecutorId', 
                            placeholder: '请选择转办人', 
                            isFilterable: true,
                            isMultiple: false,
                            options: await sysUserPage({PageNo: 1, PageSize: 999999}),
                            key: 'id',
                            opLabel: 'name',
                        }
                    ];
                    let setObjs: any = {};
                    setObjs.ruleForm = basicForms;
                    setObjs.basicInfo = modelBscs;
                    setObjs.VNodeData = modelForms;
                    setObjs.modelType = {
                        form: true,
                        upload: false,
                        table: false,
                    };
                    setObjs.rowData = val;
                    modelInfo.value = JSON.stringify(setObjs);
                    isDialog.value = true;
                    funFun = uploadFun;
                    needId = val.id;
                    break;
                case 5:
                    isPhoto.value = true;
                    photoInfo.value = JSON.stringify(val);
                    break;
                case 6:
                    resultInfo.value = JSON.stringify(val);
                    resultDialog.value = true;
                    break;
            }
        }
        const funBtn = async(url: Function, num: Number, val: any,fun: Function) => {
            let param:any = {};
            param.id = val.id;
            let res: any;
            switch(num){
                case 1:
                    param.v_Reason = val.message;
                    break;
                case 4:
                    param.id = needId;
                    param.l_ExecutorId = val.id;
                    break;
            }
            res = await url(param);
            if(res.success){
                getStateFun();
                fun();
            }
        }

        /*** nodeClick 新增/编辑点击事件 */
        const nodeClick = (val:string | object) => {
            val !== '' ? repairInfo.value = JSON.stringify(toRaw(val)) : repairInfo.value = ''
            isUseDialog.value = true
        };

        /*** deleteHandle 删除数据事件 */
        const deleteHandle = async (val: String | Number, updateFun: Function) => {
            ElMessageBox.confirm('请确定删除此条数据？','提示',
                {
                    confirmButtonText: '确定',
                    cancelButtonText: '取消',
                    type: 'warning',
                }
            )
            .then(async() => {
                let param = {id : val}
                try {
                    let res:any = await SMSIPTaskDelete(param);
                    if(res.success){
                        getStateFun();
                        updateFun();
                    }
                } catch (err) { return }
            })
            .catch(() => {
                ElMessage({
                    type: 'info',
                    message: '已取消',
                })
            })
        };

        /*** cancelUseClick 取消事件 */
        const cancelUseClick = () => {
            isUseDialog.value = false;
        };

        /*** controlUseClick 提交事件 */
        const controlUseClick = () => {
            getStateFun();
            isUseDialog.value = false;
        };

        /*** 文件上传取消事件 */
        const cancelFileClick = () => {
            fileDialog.value = false;
        };

        /*** 文件上传提交事件 */
        const controlFileClick = () => {
            getStateFun();
            fileDialog.value = false;
        }

        /*** 表单模型操作 */
        const isDialog = ref(false); // 表单模型变量
        /*** 表单模型取消 */
        const cancelModelClick = () => {
            isDialog.value = false;
        }
        /*** 表单模型提交 */
        const controlModelClick = (val: any) => {
            let submitInfo = val.setFormData;
            if(Object.keys(submitInfo).length !== 0){
                Object.keys(submitInfo).map((item: any) => {
                    funBtn(SMSIPTaskTransfer,4,submitInfo[item],funFun)
                })
            }
            getStateFun();
            isDialog.value = false;
        }
        /*** 表单模型操作 */

        /*** 获取状态信息 */
        const getStateFun = async() => {
            let param = {
                onlyMyRecord: false,
                isContainMyCreate: false,
                isContainNullEndDate: true,
                n_IPClass: 0,
            };
            let res: any = await SMSIPTaskTaskStatisticsRecordCount(param);
            if(res.success) Object.assign(state, res.data);
        }

        /** 问题随手拍取消事件 */
        const cancelPhotoClick = () => {
            isPhoto.value = false;
        }

        /*** 任务各种数量点击事件 */
        const stateClick = (val: number) => {
            setItemClass.value = val;
            if(val === 6){
                resetClick();
            }else{
                searchObj.n_State = val;
            }
            getStateFun();
        }

        /*** 登记巡检结果取消事件 */
        const cancelResultClick = () => {
            resultDialog.value = false;
        }
        /*** 登记巡检结果确定事件 */
        const controlResultClick = () => {
            getStateFun();
            resultDialog.value = false;
        }

        /*** 隐患结果 */
        const resultHandle = (num: number , val: any) => {
            console.log(num,'num')
            if(num === 0 || num === 1){
                val.state_val = num;
                effectInfo.value = JSON.stringify(val);
                effectDialog.value = true;
            }
            if(num === 2){
                dispInfo.value = JSON.stringify(val);
                dispDialog.value = true;
            }
        }

        /*** 处理过程取消事件 */
        const dispClick = () => {
            dispDialog.value = false;
        }

        const effectClick = () => {
            effectDialog.value = false;
        }

        /*** ================================= 详情类数据操作 =================================  */
        const MdetailDialog = ref(false);
        const detailInfo = ref();
        /*** 获取详情接口数据 */
        const getDetailFun = async (id: number) => {
            let res: any = await SMSIPTaskDetail({id: id}); // 详情
            if(res.success){
                let setArr: any = [];
                let detailObj: any = {};
                let smsipTaskUsers = '-';
                let smsipTaskTeamGroups = '-';
                let smsipTaskPoss = '-';
                if(res.data.smsipTaskUsers && res.data.smsipTaskUsers.length !== 0){
                    let setArr: any = [];
                    res.data.smsipTaskUsers.map((item: any) => {
                        setArr.push(item.v_UserName);
                    });
                    smsipTaskUsers = setArr.join(',');
                }
                if(res.data.smsipTaskTeamGroups && res.data.smsipTaskTeamGroups.length !== 0){
                    let setArr: any = [];
                    res.data.smsipTaskTeamGroups.map((item: any) => {
                        setArr.push(item.v_TeamGroupName);
                    });
                    smsipTaskTeamGroups = setArr.join(',');
                }
                if(res.data.smsipTaskPoss && res.data.smsipTaskPoss.length !== 0){
                    let setArr: any = [];
                    res.data.smsipTaskPoss.map((item: any) => {
                        setArr.push(item.v_PosName);
                    });
                    smsipTaskPoss = setArr.join(',');
                }
                if(res.data.ipPlan){
                    let ipPlan = res.data.ipPlan;
                    let detailObjPlan: any = {};
                    let smsipPlanUsers = '-';
                    let smsipPlanTeamGroups = '-';
                    let smsipPlanPoss = '-';
                    if(ipPlan.smsipPlanUsers && ipPlan.smsipPlanUsers.length !== 0){
                        let setArr: any = [];
                        ipPlan.smsipPlanUsers.map((item: any) => {
                            setArr.push(item.v_UserName);
                        });
                        smsipPlanUsers = setArr.join(',');
                    }
                    if(ipPlan.smsipPlanTeamGroups && ipPlan.smsipPlanTeamGroups.length !== 0){
                        let setArr: any = [];
                        ipPlan.smsipPlanTeamGroups.map((item: any) => {
                            setArr.push(item.v_TeamGroupName);
                        });
                        smsipPlanTeamGroups = setArr.join(',');
                    }
                    if(ipPlan.smsipPlanPoss && ipPlan.smsipPlanPoss.length !== 0){
                        let setArr: any = [];
                        ipPlan.smsipPlanPoss.map((item: any) => {
                            setArr.push(item.v_PosName);
                        });
                        smsipPlanPoss = setArr.join(',');
                    }
                    detailObjPlan['巡检路线'] = ipPlan.v_IPPathName;
                    detailObjPlan['风险分区'] = ipPlan.v_RiskPartitionName;
                    detailObjPlan['计划名称'] = ipPlan.v_Name;
                    detailObjPlan['巡检分类'] = ipPlan.v_IPClassName;
                    detailObjPlan['巡检类型'] = ipPlan.v_IPType;
                    detailObjPlan['巡检模式'] = ipPlan.v_IPModeName;
                    detailObjPlan['巡检周期值'] = ipPlan.n_IPCycleVaule;
                    detailObjPlan['巡检时间单位'] = ipPlan.v_IPCycleUintName;
                    detailObjPlan['开始日期'] = ipPlan.d_StartDate;
                    detailObjPlan['是否有结束日期'] = ipPlan.isAppointEndDate ? '是' : '否';
                    detailObjPlan['指定结束日期'] = ipPlan.d_EndDate;
                    detailObjPlan['重复几次结束'] = ipPlan.n_RepetitionTimesEnd;
                    detailObjPlan['开始时间'] = ipPlan.d_StartTime;
                    detailObjPlan['结束时间'] = ipPlan.d_EndTime;
                    detailObjPlan['工作日历'] = ipPlan.v_WorkingCalendarName;
                    detailObjPlan['是否启动巡检路线顺序'] = ipPlan.isUsedPathUnitOrder ? '是' : '否';
                    detailObjPlan['是否启动巡检定位'] = ipPlan.isUsedLocation ? '是' : '否';
                    detailObjPlan['巡检允许提前时间值'] = ipPlan.n_AllowEarlyValue;
                    detailObjPlan['巡检允许提前时间单位'] = ipPlan.v_AllowEarlyUnitName;
                    detailObjPlan['巡检允许延后时间值'] = ipPlan.n_AllowDelayedValue;
                    detailObjPlan['巡检允许延后时间单位'] = ipPlan.v_AllowDelayedUnitName;
                    detailObjPlan['任务生成模式'] = ipPlan.v_TaskGenerateModelName;
                    detailObjPlan['启动状态'] = ipPlan.v_StateName;
                    detailObjPlan['任务分配人员'] = smsipPlanUsers;
                    detailObjPlan['任务分配班组'] = smsipPlanTeamGroups;
                    detailObjPlan['任务分配岗位'] = smsipPlanPoss;
                    setArr.push({
                        formTitle: '巡检计划基础信息',
                        type: 'form',
                        info: detailObjPlan,
                    });
                }
                detailObj['巡检计划'] = res.data.v_IPPlanName;
                detailObj['风险分区'] = res.data.v_RiskPartitionName;
                detailObj['巡检分类'] = res.data.v_IPClassName;
                detailObj['任务状态'] = res.data.v_StateName;
                detailObj['巡检路线'] = res.data.v_IPPathName;
                detailObj['巡检类型'] = res.data.v_IPType;
                detailObj['计划开始时间'] = res.data.d_PlanStartTime;
                detailObj['计划结束时间'] = res.data.d_PlanEndTime;
                detailObj['实际开始时间'] = res.data.d_StartTime;
                detailObj['实际结束时间'] = res.data.d_EndTime;
                detailObj['实际执行人'] = res.data.v_ExecutorName;
                detailObj['执行部门'] = res.data.v_ExecutorDeptName;
                detailObj['任务分配人员'] = smsipTaskUsers;
                detailObj['任务分配班组'] = smsipTaskTeamGroups;
                detailObj['任务分配岗位'] = smsipTaskPoss;
                detailObj['是否启动巡检路线顺序'] = res.data.isUsedPathUnitOrder ? '是' : '否';
                detailObj['是否启动巡检定位'] = res.data.isUsedLocation ? '是' : '否';
                detailObj['巡检允许提前时间值'] = res.data.n_AllowEarlyValue;
                detailObj['巡检允许提前时间单位'] = res.data.v_AllowEarlyUnitName;
                detailObj['巡检允许延后时间值'] = res.data.n_AllowDelayedValue;
                detailObj['巡检允许延后时间单位'] = res.data.v_AllowDelayedUnitName;
                detailObj['任务生成模式'] = res.data.v_TaskGenerateModelName;
                detailObj['启动状态'] = res.data.v_StateName;
                detailObj['任务分配人员'] = smsipTaskUsers;
                detailObj['任务分配班组'] = smsipTaskTeamGroups;
                detailObj['任务分配岗位'] = smsipTaskPoss;
                detailObj['分配类型'] = res.data.v_AllocationType;
                setArr.push({
                    formTitle: '巡检任务基础信息',
                    type: 'form',
                    info: detailObj,
                });
                detailInfo.value = setArr;
                MdetailDialog.value = true;
            }
        }
        /*** 详情 */
        const detailHandle = (id: number) => {
            getDetailFun(id);
        }
        /*** 详情关闭事件 */
        const cancelDetailClick = () => {
            MdetailDialog.value = false;
        }
        /*** ================================= 详情类数据操作 =================================  */
        
        /*** ================================= 查询类数据操作 =================================  */
        let searchObj:any = reactive({
            onlyMyRecord: false,
            isContainMyCreate: false,
            isContainNullEndDate: true,
            n_IPClass: 0,
        });
        const basicsInfo: any = ref([]);
        const searInfo: any = ref();

        /*** 获取需要查询的数据 */
        const searchHandel = (val: any) => {
            searInfo.value = val;
        }

        /*** 合法性判断 */
        const legalFun = async (valOne: any, valTwo: any, hintTitle: string, hintInfo: string) => {
            let isLegal = true;
            if(valTwo && !valOne){
                ElMessage({
                    type: 'error',
                    message: hintTitle,
                });
                isLegal = false;
            }
            if(valOne && valTwo){
                const dateMin = new Date(valOne).getTime();
                const dateMax = new Date(valTwo).getTime();
                console.log(dateMin,dateMax,'dateMax')
                if(dateMin >= dateMax){
                    ElMessage({
                        type: 'error',
                        message: hintInfo,
                    });
                    isLegal = false;
                }
            }
            return isLegal;
        }

        /*** 查询按钮 */
        const searchClick = async () => {
            let isLegal = true;
            if(searInfo.value.d_PlanEndTimeMax){
                isLegal = await legalFun(
                    searInfo.value.d_PlanStartTimeMin, 
                    searInfo.value.d_PlanEndTimeMax, 
                    '请选择计划开始时间',
                    '计划开始时间不能大于或等于计划结束时间'
                ); 
            }
            if(searInfo.value.d_EndTimeMax){
                isLegal = await legalFun(
                    searInfo.value.d_StartTimeMin, 
                    searInfo.value.d_EndTimeMax, 
                    '请选择实际开始时间',
                    '实际开始时间不能大于或等于实际结束时间'
                );
            }
            if(!isLegal) return;

            let newObj = Object.keys(searInfo.value);
            if(newObj.length !== 0){
                newObj.map((i:any) => {
                    searchObj[i] = searInfo.value[i];
                });
            }
        };

        /*** 重置按钮 */
        const resetClick = () => {
            searInfo.value = {};
            let newObj = Object.keys(searchObj);
            if(newObj.length !== 0){
                newObj.map((i:any) => {
                    searchObj[i] = ''
                });
            }
            setItemClass.value = 6;
            searchObj.onlyMyRecord = false;
            searchObj.isContainMyCreate = false;
            searchObj.isContainNullEndDate = true;
            searchObj.n_IPClass = 0;
            getStateFun();
            initInfoFun();
        };
        
        let planArr: any = [];
        let riskArr: any = [];
        let pathArr: any = [];
        let typeArr: any = [];
        let executorArr: any = [];
        let deptArr: any = [];
        // 获取数据
        const getFun = async () => {
            let ras: any = await SMSIPPathList({}); // 巡检路线
            let rbs: any = await SMSDCRiskPartitionList({}); // 风险分区
            let rcs: any = await sysDictDataList({TypeCode: 'pollingType'}); // 巡检类型
            let rds: any = await SMSIPPlanList({}); // 巡检计划
            let res: any = await sysOrgTree({}); // 部门
            let rfs: any = await sysUserselectorV2({}); // 用户
            if(ras.success && ras.data.length !== 0){
                ras.data.map((item: any) => {
                    item.label = item.v_Name;
                    item.value = item.id;
                });
                pathArr = ras.data;
            }
            if(rbs.success && rbs.data.length !== 0){
                rbs.data.map((item: any) => {
                    item.label = item.v_Name;
                    item.value = item.id;
                });
                riskArr = rbs.data;
            }
            if(rcs.success && rcs.data.length !== 0){
                console.log(rcs,'rcs')
                rcs.data.map((item: any) => {
                    item.label = item.value;
                    item.value = item.value;
                });
                typeArr = rcs.data;
            }
            if(rds.success && rds.data.length !== 0){
                rds.data.map((item: any) => {
                    item.label = item.v_Name;
                    item.value = item.id;
                });
                planArr = rds.data;
            }
            if(res.success && res.data.length !== 0) deptArr = res.data;
            if(rfs.success && rfs.data.length !== 0){
                rfs.data.map((item: any) => {
                    item.label = item.name;
                    item.value = item.id;
                });
                executorArr = rfs.data;
            }
        }
        
        /*** 初始化数据 */
        const initInfoFun = () => {
            basicsInfo.value = [{
                    typeId: 'i_Name', // 类型(不能为空，且唯一，与组件中typeId值对应) --- 必填
                    typeNam: '', // 输入类型(number,text等) --- 选填
                    searchVal: 'v_Name', // 查询字段 --- 必填
                    defaultVal: '', // 字段默认值 --- 选填
                    placeholder: '任务名称', // placeholder数据
                    defaultProp: '', // 下拉框中使用，除下拉框外其它情况为空 --- 选填
                    eventType: '', // 事件类型（如burl/change等） --- 选填
                    defaultEvent: '', // 事件名称 --- 选填
                },{
                    typeId: 's_Plan', // 类型(不能为空，且唯一，与组件中typeId值对应) --- 必填
                    typeNam: '', // 输入类型(number,text等) --- 选填
                    searchVal: 'l_IPPlanId', // 查询字段 --- 必填
                    defaultVal: '', // 字段默认值 --- 选填
                    placeholder: '巡检计划', // placeholder数据
                    defaultProp: planArr, // 下拉框中使用，除下拉框外其它情况为空 --- 选填
                    eventType: '', // 事件类型（如burl/change等） --- 选填
                    defaultEvent: '', // 事件名称 --- 选填
                },{
                    typeId: 's_Risk', // 类型(不能为空，且唯一，与组件中typeId值对应) --- 必填
                    typeNam: '', // 输入类型(number,text等) --- 选填
                    searchVal: 'l_RiskPartitionId', // 查询字段 --- 必填
                    defaultVal: '', // 字段默认值 --- 选填
                    placeholder: '风险分区', // placeholder数据
                    defaultProp: riskArr, // 下拉框中使用，除下拉框外其它情况为空 --- 选填
                    eventType: '', // 事件类型（如burl/change等） --- 选填
                    defaultEvent: '', // 事件名称 --- 选填
                },{
                    typeId: 's_State', // 类型(不能为空，且唯一，与组件中typeId值对应) --- 必填
                    typeNam: '', // 输入类型(number,text等) --- 选填
                    searchVal: 'n_State', // 查询字段 --- 必填
                    defaultVal: '', // 字段默认值 --- 选填
                    placeholder: '任务状态', // placeholder数据
                    defaultProp: [
                        {label: '待提交', value: 0},
                        {label: '未开始', value: 1},
                        {label: '执行中', value: 2},
                        {label: '已完成', value: 3},
                        {label: '漏捡', value: 4},
                        {label: '取消', value: 5},
                    ], // 下拉框中使用，除下拉框外其它情况为空 --- 选填
                    eventType: '', // 事件类型（如burl/change等） --- 选填
                    defaultEvent: '', // 事件名称 --- 选填
                },{
                    typeId: 's_Path', // 类型(不能为空，且唯一，与组件中typeId值对应) --- 必填
                    typeNam: '', // 输入类型(number,text等) --- 选填
                    searchVal: 'l_IPPathId', // 查询字段 --- 必填
                    defaultVal: '', // 字段默认值 --- 选填
                    placeholder: '巡检路线', // placeholder数据
                    defaultProp: pathArr, // 下拉框中使用，除下拉框外其它情况为空 --- 选填
                    eventType: '', // 事件类型（如burl/change等） --- 选填
                    defaultEvent: '', // 事件名称 --- 选填
                },{
                    typeId: 's_Type', // 类型(不能为空，且唯一，与组件中typeId值对应) --- 必填
                    typeNam: '', // 输入类型(number,text等) --- 选填
                    searchVal: 'v_IPType', // 查询字段 --- 必填
                    defaultVal: '', // 字段默认值 --- 选填
                    placeholder: '巡检类型', // placeholder数据
                    defaultProp: typeArr, // 下拉框中使用，除下拉框外其它情况为空 --- 选填
                    eventType: '', // 事件类型（如burl/change等） --- 选填
                    defaultEvent: '', // 事件名称 --- 选填
                },{
                    typeId: 'd_Start', // 类型(不能为空，且唯一，与组件中typeId值对应) --- 必填
                    typeNam: '', // 输入类型(number,text等) --- 选填
                    searchVal: 'd_PlanStartTimeMin', // 查询字段 --- 必填
                    // searchValMax: 'd_PlanStartTimeMax', // 查询字段 --- 必填
                    defaultVal: '', // 字段默认值 --- 选填
                    placeholder: '任务计划开始时间', // placeholder数据
                    defaultProp: '', // 下拉框中使用，除下拉框外其它情况为空 --- 选填
                    eventType: '', // 事件类型（如burl/change等） --- 选填
                    defaultEvent: '', // 事件名称 --- 选填
                },{
                    typeId: 'd_End', // 类型(不能为空，且唯一，与组件中typeId值对应) --- 必填
                    typeNam: '', // 输入类型(number,text等) --- 选填
                    // searchValMin: 'd_PlanEndTimeMin', // 查询字段 --- 必填
                    searchVal: 'd_PlanEndTimeMax', // 查询字段 --- 必填
                    defaultVal: '', // 字段默认值 --- 选填
                    placeholder: '任务计划结束时间', // placeholder数据
                    defaultProp: '', // 下拉框中使用，除下拉框外其它情况为空 --- 选填
                    eventType: '', // 事件类型（如burl/change等） --- 选填
                    defaultEvent: '', // 事件名称 --- 选填
                },{
                    typeId: 'd_StartTime', // 类型(不能为空，且唯一，与组件中typeId值对应) --- 必填
                    typeNam: '', // 输入类型(number,text等) --- 选填
                    searchVal: 'd_StartTimeMin', // 查询字段 --- 必填
                    // searchValMax: 'd_StartTimeMax', // 查询字段 --- 必填
                    defaultVal: '', // 字段默认值 --- 选填
                    placeholder: '任务实际开始时间', // placeholder数据
                    defaultProp: '', // 下拉框中使用，除下拉框外其它情况为空 --- 选填
                    eventType: '', // 事件类型（如burl/change等） --- 选填
                    defaultEvent: '', // 事件名称 --- 选填
                },{
                    typeId: 'd_EndTime', // 类型(不能为空，且唯一，与组件中typeId值对应) --- 必填
                    typeNam: '', // 输入类型(number,text等) --- 选填
                    // searchValMin: 'd_EndTimeMin', // 查询字段 --- 必填
                    searchVal: 'd_EndTimeMax', // 查询字段 --- 必填
                    defaultVal: '', // 字段默认值 --- 选填
                    placeholder: '任务实际结束时间', // placeholder数据
                    defaultProp: '', // 下拉框中使用，除下拉框外其它情况为空 --- 选填
                    eventType: '', // 事件类型（如burl/change等） --- 选填
                    defaultEvent: '', // 事件名称 --- 选填
                },{
                    typeId: 's_Executor', // 类型(不能为空，且唯一，与组件中typeId值对应) --- 必填
                    typeNam: '', // 输入类型(number,text等) --- 选填
                    searchVal: 'l_ExecutorId', // 查询字段 --- 必填
                    defaultVal: '', // 字段默认值 --- 选填
                    placeholder: '实际执行人', // placeholder数据
                    defaultProp: executorArr, // 下拉框中使用，除下拉框外其它情况为空 --- 选填
                    eventType: '', // 事件类型（如burl/change等） --- 选填
                    defaultEvent: '', // 事件名称 --- 选填
                },{
                    typeId: 's_Dept', // 类型(不能为空，且唯一，与组件中typeId值对应) --- 必填
                    typeNam: '', // 输入类型(number,text等) --- 选填
                    searchVal: 'l_ExecutorDeptId', // 查询字段 --- 必填
                    defaultVal: '', // 字段默认值 --- 选填
                    placeholder: '实际执行人部门', // placeholder数据
                    defaultProp: deptArr, // 下拉框中使用，除下拉框外其它情况为空 --- 选填
                    eventType: '', // 事件类型（如burl/change等） --- 选填
                    defaultEvent: '', // 事件名称 --- 选填
                    propsVal: { checkStrictly: true , label: 'title', value: 'id', children: 'children' }, // 级联选择器 --- 选填
                }
            ]
        }
        
        onMounted(async () => {
            await getStateFun();
            await getFun();
            initInfoFun(); 
        });
        /*** ================================= 查询类数据操作 =================================  */

        /*** ================================= 导出数据函数操作 ================================= */
        const excelRef: any = ref(null);
        const handleExport = () => {
            if(excelRef){
                if(excelRef.value.data.length !== 0){
                    let tableExcel: any = [];
                    let tableArr = excelRef.value.data;
                    tableArr.map((item: any) => {
                        let tableObj: any = {};
                        tableObj['任务名称'] = item.v_Name ? item.v_Name : '-';
                        tableObj['巡检计划'] = item.v_IPPlanName ? item.v_IPPlanName : '-';
                        tableObj['风险分区'] = item.v_RiskPartitionName ? item.v_RiskPartitionName : '-';
                        tableObj['巡检分类'] = item.v_IPClassName ? item.v_IPClassName : '-';
                        tableObj['任务状态'] = item.v_StateName ? item.v_StateName : '-';
                        tableObj['巡检路线'] = item.v_IPPathName ? item.v_IPPathName : '-';
                        tableObj['巡检类型'] = item.v_IPType ? item.v_IPType : '-';
                        tableObj['计划开始时间'] = item.d_PlanStartTime ? item.d_PlanStartTime : '-';
                        tableObj['计划结束时间'] = item.d_PlanEndTime ? item.d_PlanEndTime : '-';
                        tableObj['实际开始时间'] = item.d_StartTime ? item.d_StartTime : '-';
                        tableObj['实际结束时间'] = item.d_EndTime ? item.d_EndTime : '-';
                        tableObj['实际执行人'] = item.v_ExecutorName ? item.v_ExecutorName : '-';
                        tableObj['执行部门'] = item.v_ExecutorDeptName ? item.v_ExecutorDeptName : '-';
                        tableObj['是否启动巡检路线顺序'] = item.isUsedPathUnitOrder ? '是' : '否';
                        tableObj['是否启动巡检定位'] = item.isUsedLocation ? '是' : '否';
                        tableObj['启动状态'] = item.v_StateName ? item.v_StateName : '-';
                        tableObj['分配类型'] = item.v_AllocationType ? item.v_AllocationType : '-';
                        tableExcel.push(tableObj);
                    });
                    exportToExcel(tableExcel,'设备巡检任务台账.xlsx');
                }else{
                    ElMessage({
                        type: 'error',
                        message: '暂无数据导出',
                    })
                }
            }
        }
        /*** ================================= 导出数据函数操作 ================================= */

        return {
            ...getTableData(SMSIPTaskPage,{},searchObj),
            state,
            isUseDialog,
            cancelUseClick,
            controlUseClick,
            nodeClick,
            repairInfo,
            deleteHandle,
            funClick,
            isDialog,
            cancelModelClick,
            controlModelClick,
            modelInfo,
            fileInfo,
            fileDialog,
            cancelFileClick,
            controlFileClick,
            isPhoto,
            photoInfo,
            cancelPhotoClick,
            stateClick,
            resultDialog,
            resultInfo,
            cancelResultClick,
            controlResultClick,
            setItemClass,
            handleSelectionChange,
            syncHandle,

            // 导出Excel
            excelRef,
            handleExport,
            
            // 处理过程
            dispInfo,
            dispDialog,
            dispClick,

            effectClick,
            effectDialog,
            effectInfo,
            resultHandle,
            
            // 详情
            MdetailDialog,
            detailHandle,
            detailInfo,
            cancelDetailClick,

            // 查询事件
            basicsInfo,
            searchHandel,
            searchClick,
            resetClick,
        }
    },
} )
</script>
<style lang="scss"> @import '../style/public.scss'; </style>
<style scoped lang="scss">
    ul {
        list-style: none;
        li {
            cursor: pointer;
            border-bottom: 1px solid rgba(255,255,255,0.1);
            text-align: center;
            padding: 10px 0;
        }
    }
    .set-border{
        border: 1px solid transparent !important;
    }
    .itemClass{
        border: 1px solid #E6A23C !important;
        border-radius: 4px;
        padding: 15px;
    }
    .search-s{
        display: flex;
        flex-direction: row;
        justify-content: space-between;
        align-items: center;
        margin-bottom: 20px;
        width: 100%;
        .search-s-l{
            display: flex;
            flex-direction: row;
            justify-content: flex-start;
            align-items: center;
            width: 98%;
        }
    }
    #inspection-task {
        .box-f{
            :deep(.el-form-item__label){
                padding: 0;
            }
        }
        :deep(.el-card__body) {
            height: 100%;
        }
        :deep(.el-card){
            border: none !important;
        }
        .upload-demo{
            margin-left: 12px;
            margin-top: 2px;
        }
        .icon-e{
            :deep(.el-icon){
                margin-right: 0px!important;
            }
        }
    }
.clear-bg{
    background-color: transparent !important;
}
</style>